package com.power.sifa.approve.dao;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.Repository;
import org.springframework.data.repository.query.Param;
import com.power.sifa.approve.model.Apl_applicant;

import javax.transaction.Transactional;
import java.io.Serializable;
import java.util.List;
import java.util.Map;

/**
 * 申请人 持久层(hibernate)
 */

public interface Apl_applicantDao extends JpaRepository<Apl_applicant, Serializable>, JpaSpecificationExecutor<Apl_applicant>, Repository<Apl_applicant, Serializable>, Apl_applicantDaoCustom<Apl_applicant, Serializable> {

   @Modifying
   @Transactional
   @Query("delete  from Apl_applicant s where  s.id in (:ids) ")
   void removeByIds(@Param("ids") List<Integer> ids);

   @Query(" from Apl_applicant s where  s.applyid = :applyid")
   List<Apl_applicant> getByApplyid(@Param("applyid") String applyid);

   @Query(value = "select distinct cardno, id, name FROM Apl_applicant where name like :name  group by id ", nativeQuery = true)
   List<Map<String,Object>> searchCardNoByName(@Param("name") String name);

   @Query(" from Apl_applicant s where s.id in (:ids)")
   List<Apl_applicant> getByIds(@Param("ids") List<String> ids);
}
